package com.souku.finance.application.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.souku.finance.application.R;

/**
 * Created by Android on 2017/1/11.
 */

public class WaitDialog extends Dialog {

    protected RelativeLayout relative;
    protected TextView tvFinish;
    private Handler mHandle=new Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            dismiss();
            relative.setVisibility(View.VISIBLE);
            tvFinish.setVisibility(View.GONE);
        }
    };

    public WaitDialog(Context context) {
        super(context, R.style.myDialogThemeno);
    }

    public WaitDialog(Context context, int themeResId) {
        super(context, themeResId);
    }

    protected WaitDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_wait);
        initView();
    }

    private void initView() {
        relative = (RelativeLayout)findViewById(R.id.relative);
        tvFinish = (TextView)findViewById(R.id.tv_finish);
    }

    public void setfinish(String s){
        relative.setVisibility(View.GONE);
        tvFinish.setVisibility(View.VISIBLE);
        tvFinish.setText(s);
        mHandle.sendEmptyMessage(0);
    }
}
